<?php


class Login extends CI_Controller{

    function __construct(){
        parent::__construct();
        $this->load->helper('url');
    }


    public function index($msg = NULL){
        $data['registros'] = array();
        $menu['selectLabel'] = '';
        $data['msg'] = $msg;

        $this->load->view('pages/admin/templates/header_login',$menu);
        $this->load->view('pages/admin/v_login',$data);
        $this->load->view('pages/admin/templates/footer');

    }

    public function process(){
        $this->load->helper('form');

        $usuario= $this->input->post('usuario');
        $clave= $this->input->post('clave');
        $result = $usuario=="admin" && $clave=="##quigrafin##";
        // Now we verify the result
        if(!$result){
            // If user did not validate, then show them login page again
            $msg = '<font color=red>Usuario y/o clave invalida.</font><br />';
            $this->index($msg);
        }else{
            // If user did validate,
            // Send them to members area
            $data = array(
                'userid' => 'admin',
                'fname' => '',
                'lname' => '',
                'username' => 'admin',
                'validated' => true
            );
            $this->session->set_userdata($data);
            redirect('panel');
        }


    }

    public function do_logout(){
        $this->session->sess_destroy();
        redirect('login');
    }
}


?>